package com.lengxf.design;

import java.util.Hashtable;

/**
 * 享元工厂类
 * By Lengxf
 */
public class IgoChessmanFactory {

    private static final IgoChessmanFactory instance = new IgoChessmanFactory();
    private static Hashtable<String, IgoChessman> ht;

    public IgoChessmanFactory() {
        ht = new Hashtable<>();
        IgoChessman black, white;
        black = new BlackIgoChessman();
        white = new WhiteIgoChessman();
        ht.put("b", black);
        ht.put("w", white);
    }

    public static IgoChessmanFactory getInstance() {
        return instance;
    }

    public IgoChessman getIgoChessman(String color) {
        return ht.get(color);
    }


}
